Telegram Group & Telegram Channel
🧙‍♂️ Атрибуты в современном C++

В C++11 и новее появились атрибуты — механизм, о котором многие забывают. Атрибуты позволяют передавать дополнительную информацию компилятору, не меняя семантику кода.

[[nodiscard]] int getValue() { return 42; }

void test() {
getValue(); // Предупреждение: результат функции не используется
}

class [[deprecated("Используйте новый API")]] OldClass {};

[[noreturn]] void throwError() { throw std::runtime_error("Ошибка"); }

// C++20: говорит компилятору, что код с [[likely]] будет выполняться чаще
void process(int* data) {
if (data) [[likely]] {
process_data(data);
} else [[unlikely]] {
handle_null();
}
}

Другие полезные атрибуты: [[maybe_unused]], [[fallthrough]], [[no_unique_address]] (C++20). Они делают код понятнее и помогают избежать ошибок😸

Библиотека C/C++ разработчика #буст



tg-me.com/cppproglib/5658
Create:
Last Update:

🧙‍♂️ Атрибуты в современном C++

В C++11 и новее появились атрибуты — механизм, о котором многие забывают. Атрибуты позволяют передавать дополнительную информацию компилятору, не меняя семантику кода.

[[nodiscard]] int getValue() { return 42; }

void test() {
getValue(); // Предупреждение: результат функции не используется
}

class [[deprecated("Используйте новый API")]] OldClass {};

[[noreturn]] void throwError() { throw std::runtime_error("Ошибка"); }

// C++20: говорит компилятору, что код с [[likely]] будет выполняться чаще
void process(int* data) {
if (data) [[likely]] {
process_data(data);
} else [[unlikely]] {
handle_null();
}
}

Другие полезные атрибуты: [[maybe_unused]], [[fallthrough]], [[no_unique_address]] (C++20). Они делают код понятнее и помогают избежать ошибок😸

Библиотека C/C++ разработчика #буст

BY Библиотека C/C++ разработчика | cpp, boost, qt


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/cppproglib/5658

View MORE
Open in Telegram


Библиотека C C разработчика | cpp boost qt Telegram | DID YOU KNOW?

Date: |

Telegram Auto-Delete Messages in Any Chat

Some messages aren’t supposed to last forever. There are some Telegram groups and conversations where it’s best if messages are automatically deleted in a day or a week. Here’s how to auto-delete messages in any Telegram chat. You can enable the auto-delete feature on a per-chat basis. It works for both one-on-one conversations and group chats. Previously, you needed to use the Secret Chat feature to automatically delete messages after a set time. At the time of writing, you can choose to automatically delete messages after a day or a week. Telegram starts the timer once they are sent, not after they are read. This won’t affect the messages that were sent before enabling the feature.

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

Библиотека C C разработчика | cpp boost qt from ms


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM USA